package leetcode.code2150;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import leetcode.IDebug;

public class Solution implements IDebug {

	public List<Integer> findLonely(int[] nums) {
		Map<Integer, Integer> map = new HashMap<>();
		for (int i = 0; i < nums.length; i++) {
			int num = nums[i];
			map.put(num, map.getOrDefault(num, 0) + 1);
		}
		List<Integer> ans = new ArrayList<>();
		for (Map.Entry<Integer, Integer> entry : map.entrySet()) {
			int num = entry.getKey(), cnt = entry.getValue();
			if (cnt == 1 && !map.containsKey(num + 1) && !map.containsKey(num - 1)) {
				ans.add(num);
			}
		}
		return ans;
	}

	@Override
	public void debug4() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug3() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug2() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug1() {
		// TODO Auto-generated method stub

	}

	public static void main(String[] args) {
		// TODO Auto-generated method stub

	}

}
